package com.tju.ffmpeg

import java.lang.StringBuilder
import java.util.Scanner
fun main(args: Array<String>) {
    val read = Scanner(System.`in`)

    var n = read.nextInt()
    val arrA: IntArray = IntArray(n) {0}
    for (i in 0 until n) {
        arrA[i] = read.nextInt()
    }
    if (n<2) {
        arrA.forEach { print(arrA[0]) }
    }
    val arrB: IntArray = IntArray(n) {0}
    for (i in 0 until n) {
        move(arrB, i)
        arrB[0] = arrA[i]
        reverse(arrB, 0, i)
    }
    arrB.forEach {
        print("$it ")
    }
}

fun move(nums: IntArray, index: Int) {
    for (i in index-1 downTo 0) {
        nums[i+1] = nums[i]
    }
}

fun reverse(nums: IntArray, start: Int, end: Int) {
    var l = start
    var r = end
    while(l<r) {
        swap(nums, l++, r--)
    }
}

fun swap(nums: IntArray, l: Int, r: Int) {
    val t = nums[l]
    nums[l] = nums[r]
    nums[r] = t
}